﻿using System;

namespace Apewer.Source
{

    /// <summary>超时。</summary>
    [Serializable]
    public class Timeout
    {

        private int _connect, _query, _execute;

        /// <summary>获取或设置超时。</summary>
        public Timeout(int connect, int query, int execute)
        {
            _connect = connect;
            _query = query;
            _execute = execute;
        }

        /// <summary>连接超时秒数。</summary>
        public int Connect
        {
            get { return _connect; }
            set { _connect = (value >= 0) ? value : 0; }
        }

        /// <summary>查询超时秒数。</summary>
        public int Query
        {
            get { return _query; }
            set { _query = (value >= 0) ? value : 0; }
        }

        /// <summary>执行超时秒数。</summary>
        public int Execute
        {
            get { return _execute; }
            set { _execute = (value >= 0) ? value : 0; }
        }

        /// <summary>默认超时设置：连接 5 秒、查询 3600 秒，执行 3600 秒。</summary>
        public static Timeout Default { get => new Timeout(5, 3600, 3600); }

    }

}